<?php

$container = $app->getContainer();

$capsule = new \Illuminate\Database\Capsule\Manager;
$capsule->addConnection($container['settings']['db'], 'default');

$capsule->setEventDispatcher(
    new \Illuminate\Events\Dispatcher(
        new \Illuminate\Container\Container
    )
);

$capsule->setAsGlobal();
$capsule->bootEloquent();

$container['logger'] = function ($container)
{
    $logger = new Monolog\Logger(getenv('LOGGER_NAME'));

    $logger->pushProcessor(new Monolog\Processor\IntrospectionProcessor());

    $logger->pushHandler(
        (new Monolog\Handler\RotatingFileHandler(getenv('LOGGER_PATH'), Monolog\Logger::DEBUG))
        ->setFormatter(new Monolog\Formatter\JsonFormatter)
    );

    return $logger;
};

// $container['cache'] = function ($container)
// {
//     $redis = new \Redis();
//     $redis->connect(getenv('REDIS_HOST'), getenv('REDIS_PORT'));
//     $redis->auth(getenv('REDIS_PASSWORD'));
//     return $redis;
// };
//
// $container["jwt"] = function ($container)
// {
//     return new StdClass;
// };
